<?php namespace Phpcmf\Controllers;

class Player extends \Phpcmf\Common {

    // 视频地址
    public function index() {

        header('Content-type: text/json');
        $rt = [
            'video' => []
        ];
        $id = intval($_GET['id']);
        $data = dr_get_video_data($id);
        if ($data) {
            $rt['video'] = $data['ckplayer_data'];
        }
        echo json_encode($rt);exit;
    }

    // 广告
    public function ad() {

        header('Content-type: text/json');
        $data = $this->get_cache('video_player_ad_'.SITE_ID);

        $rt = [];
        if ($this->player_config['ad']) {
            foreach ($this->player_config['ad'] as $tid => $v) {
                if ($v && $data[$tid]) {
                    $rt[$tid] = $data[$tid];
                }
            }
        }
        echo json_encode($rt);exit;
    }
}
